<?php
/**
 * Created by PhpStorm.
 * User: taotao
 * Date: 2019/9/23
 * Time: 15:33
 */

namespace App\Http\Service;


use App\Repositories\NewsRepository;

class NewsService
{

    public function __construct()
    {
        $this->news_repository = new NewsRepository();
    }

    /**
     * 获取用户发布的资讯列表
     * @param $uid
     * @return array
     */
    public function getUserNews($uid)
    {
        $list = $this->news_repository->getNews(1,$uid);
        return $list ? $list->toArray() : [];
    }

    /**
     * 获取资讯详情
     * @param $id
     * @return array
     */
    public function getDetailNews($id)
    {
        $list = $this->news_repository->getNewsDetail($id);
        return $list ? $list->toArray() : [];
    }

    /**
     * 获取资讯详情
     * @param $id
     * @return array
     */
    public function addNews($data)
    {
        return $this->news_repository->addNew($data);
    }

    /**
     * 获取资讯详情
     * @param $id
     * @return array
     */
    public function getNews($new_id)
    {
        return $this->news_repository->getNewsDetail($new_id);
    }

    /**
     * 更新资讯
     * @param $id
     * @return array
     */
    public function updateDetail($new_id,$data)
    {
        return $this->news_repository->updateNew($new_id,$data);
    }


}